﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="checklogin.aspx.cs" Inherits="tracnghiemonline2.Ajax.ASP.WebForm1" %>

<%@ Import Namespace="DataAccess" %>
<%@ Import Namespace="System.Linq" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <%
        string user = Request.QueryString["user"];
        string pass = Request.QueryString["Pass"];

        bool check = false;
        var checkuser = new TblUserController().FetchAll().Where(x => x.UserName.ToLower() == user.ToLower()).ToList();
        if (checkuser.Count == 1)
        {
            var get_pass = new TblUserController().FetchAll().Where(x => x.UserName.ToLower() == user.ToLower()).Single();

            if (get_pass.UserPass == pass)
            {
                check = true;
            }
            else
            {
                check = false;
            }
        }
        else
        {
            check = false;
        }

        if (check == false)
        {
    %>
    <ul class="w3-navbar w3-black w3-card-2">
        <li class="w3-hide-large w3-opennav w3-right">
            <a href="javascript:void(0);" onclick="opencolapsemenu()" class="w3-padding-16 w3-black hvr-underline-from-center"><i class="fa fa-bars"></i></a>
        </li>
        <li><a href="Default.aspx" class="w3-black w3-padding-12">
            <img src="Content/img/logosqt.png" class="w3-hide-medium w3-hide-small w3-animate-zoom" style="width: 5%" />&nbsp;<span class="w3-animate-right" style="letter-spacing: 3px">SEN Quốc Tế</span></a></li>
        <li class="w3-hide-small w3-hide-medium"><a href="Default.aspx" class="w3-padding-16 w3-black hvr-underline-from-center">Trang chủ</a></li>
        <li class="w3-hide-small w3-hide-medium"><a href="javascript:;" onclick="document.getElementById('sign-in-modal').style.display = 'block';" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng ký</a></li>
        <li class="w3-hide-small w3-hide-medium w3-dropdown-click"><a onclick="login()" href="javascript:;" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng nhập</a>
            <div id="login-form" class="w3-show login-form w3-dropdown-content w3-padding w3-black w3-card-2 w3-animate-opacity">
                <div class="w3-row w3-padding-top w3-padding-bottom">
                    <label class="w3-text-red">Sai tên tài khoản hoặc mật khẩu</label>
                </div>
                <div class="w3-row w3-padding-top w3-padding-bottom">
                    <input id="username" type="text" autofocus="autofocus" maxlength="18" required="required" placeholder="Tên đăng nhập" />
                </div>
                <div class="w3-row w3-padding-top w3-padding-bottom">
                    <input id="password" type="password" autofocus="autofocus" maxlength="18" required="required" placeholder="Mật khẩu" />
                </div>
                <div class="w3-row w3-padding-top w3-padding-bottom">
                    <p class="checkbox w3-left">
                        <input type="checkbox" id="remember" />&nbsp;<label for="remember">Ghi nhớ</label>
                    </p>
                    <p class="w3-right"><a href="javascript:;" onclick="document.getElementById('forget-pass-modal').style.display = 'block';" class="w3-black w3-text-brown w3-hover-text-white">Quên mật khẩu ?</a></p>
                </div>
                <div class="w3-row w3-padding w3-center">
                    <a href="javascript:;" class="login w3-btn w3-brown w3-hover-white w3-hover-text-brown" style="width: 100%">Đăng nhập</a>
                </div>
                <p class="w3-center">Hoặc đăng nhập bằng</p>
                <div class="w3-row w3-padding w3-center">
                    <a href="javascript:;" id="btn_login_facebook" class="w3-btn w3-indigo w3-hover-white w3-hover-text-indigo w3-half"><i class="fa fa-facebook"></i>&nbsp;Facebook</a>
                    <a href="javascript:;" id="btn_login_google" class="w3-btn w3-deep-orange w3-hover-white w3-hover-text-deep-orange w3-half"><i class="fa fa-google-plus"></i>&nbsp;Google+</a>
                </div>
            </div>
        </li>
    </ul>
    <div id="colapsemenu" class="w3-hide w3-hide-large w3-animate-top">
        <ul class="w3-navbar w3-black">
            <li><a href="Default.aspx" class="w3-padding-16 w3-black hvr-underline-from-center">Trang chủ</a></li>
            <li class="w3-hide-small"><a href="javascript:;" onclick="document.getElementById('sign-in-modal-me').style.display = 'block';opencolapsemenu();" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng ký</a></li>
            <li class="w3-hide-medium"><a href="javascript:;" onclick="document.getElementById('sign-in-modal-sm').style.display = 'block';opencolapsemenu();" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng ký</a></li>
            <li class="w3-accordion"><a onclick="login_res()" href="javascript:;" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng nhập</a>
                <div id="login-form-res" class="w3-show login-form-res w3-accordion-content w3-padding w3-black w3-card-2 w3-animate-opacity" style="height: 100px">
                    <div class="w3-row w3-padding-top w3-padding-bottom">
                        <label class="w3-text-red">Sai tên tài khoản hoặc mật khẩu</label>
                    </div>
                    <div class="w3-row w3-padding-top w3-padding-bottom">
                        <input type="text" autofocus="autofocus" maxlength="18" required="required" placeholder="Tên đăng nhập" />
                    </div>
                    <div class="w3-row w3-padding-top w3-padding-bottom">
                        <input type="password" autofocus="autofocus" maxlength="18" required="required" placeholder="Mật khẩu" />
                    </div>
                    <div class="w3-row w3-padding-top w3-padding-bottom">
                        <p class="checkbox w3-left">
                            <input type="checkbox" id="remember-res" />&nbsp;<label for="remember-res">Ghi nhớ</label>
                        </p>
                        <p class="w3-right"><a href="javascript:;" onclick="document.getElementById('forget-pass-modal').style.display = 'block';" class="w3-black w3-text-brown w3-hover-text-white">Quên mật khẩu ?</a></p>
                    </div>
                    <div class="w3-row w3-padding w3-center">
                        <a href="javascript:;" class="w3-btn w3-brown w3-hover-white w3-hover-text-brown" style="width: 100%">Đăng nhập</a>
                    </div>
                    <p class="w3-center">Hoặc đăng nhập bằng</p>
                    <div class="w3-row w3-padding w3-center">
                        <a href="javascript:;" class="w3-btn w3-indigo w3-hover-white w3-hover-text-indigo w3-half"><i class="fa fa-facebook"></i>&nbsp;Facebook</a>
                        <a href="javascript:;" class="w3-btn w3-deep-orange w3-hover-white w3-hover-text-deep-orange w3-half"><i class="fa fa-google-plus"></i>&nbsp;Google+</a>
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <%
        }
        else
        {
            if (checkuser[0].Active == false)
            {
                %>
    <ul class="w3-navbar w3-black w3-card-2">
        <li class="w3-hide-large w3-opennav w3-right">
            <a href="javascript:void(0);" onclick="opencolapsemenu()" class="w3-padding-16 w3-black hvr-underline-from-center"><i class="fa fa-bars"></i></a>
        </li>
        <li><a href="Default.aspx" class="w3-black w3-padding-12">
            <img src="Content/img/logosqt.png" class="w3-hide-medium w3-hide-small w3-animate-zoom" style="width: 5%" />&nbsp;<span class="w3-animate-right" style="letter-spacing: 3px">SEN Quốc Tế</span></a></li>
        <li class="w3-hide-small w3-hide-medium"><a href="Default.aspx" class="w3-padding-16 w3-black hvr-underline-from-center">Trang chủ</a></li>
        <li class="w3-hide-small w3-hide-medium"><a href="javascript:;" onclick="document.getElementById('sign-in-modal').style.display = 'block';" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng ký</a></li>
        <li class="w3-hide-small w3-hide-medium w3-dropdown-click"><a onclick="login()" href="javascript:;" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng nhập</a>
            <div id="login-form" class="w3-show login-form w3-dropdown-content w3-padding w3-black w3-card-2 w3-animate-opacity">
                <div class="w3-row w3-padding-top w3-padding-bottom">
                    <label class="w3-text-red">Tài khoản của bạn đã bị khóa!</label>
                </div>
                <div class="w3-row w3-padding-top w3-padding-bottom">
                    <input id="username" type="text" autofocus="autofocus" maxlength="18" required="required" placeholder="Tên đăng nhập" />
                </div>
                <div class="w3-row w3-padding-top w3-padding-bottom">
                    <input id="password" type="password" autofocus="autofocus" maxlength="18" required="required" placeholder="Mật khẩu" />
                </div>
                <div class="w3-row w3-padding-top w3-padding-bottom">
                    <p class="checkbox w3-left">
                        <input type="checkbox" id="remember" />&nbsp;<label for="remember">Ghi nhớ</label>
                    </p>
                    <p class="w3-right"><a href="javascript:;" onclick="document.getElementById('forget-pass-modal').style.display = 'block';" class="w3-black w3-text-brown w3-hover-text-white">Quên mật khẩu ?</a></p>
                </div>
                <div class="w3-row w3-padding w3-center">
                    <a href="javascript:;" class="login w3-btn w3-brown w3-hover-white w3-hover-text-brown" style="width: 100%">Đăng nhập</a>
                </div>
                <p class="w3-center">Hoặc đăng nhập bằng</p>
                <div class="w3-row w3-padding w3-center">
                    <a href="javascript:;" class="w3-btn w3-indigo w3-hover-white w3-hover-text-indigo w3-half"><i class="fa fa-facebook"></i>&nbsp;Facebook</a>
                    <a href="javascript:;" class="w3-btn w3-deep-orange w3-hover-white w3-hover-text-deep-orange w3-half"><i class="fa fa-google-plus"></i>&nbsp;Google+</a>
                </div>
            </div>
        </li>
    </ul>
    <div id="colapsemenu" class="w3-hide w3-hide-large w3-animate-top">
        <ul class="w3-navbar w3-black">
            <li><a href="Default.aspx" class="w3-padding-16 w3-black hvr-underline-from-center">Trang chủ</a></li>
            <li class="w3-hide-small"><a href="javascript:;" onclick="document.getElementById('sign-in-modal-me').style.display = 'block';opencolapsemenu();" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng ký</a></li>
            <li class="w3-hide-medium"><a href="javascript:;" onclick="document.getElementById('sign-in-modal-sm').style.display = 'block';opencolapsemenu();" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng ký</a></li>
            <li class="w3-accordion"><a onclick="login_res()" href="javascript:;" class="w3-padding-16 w3-black hvr-underline-from-center">Đăng nhập</a>
                <div id="login-form-res" class="w3-show login-form-res w3-accordion-content w3-padding w3-black w3-card-2 w3-animate-opacity" style="height: 100px">
                    <div class="w3-row w3-padding-top w3-padding-bottom">
                        <label class="w3-text-red">Sai tên tài khoản hoặc mật khẩu</label>
                    </div>
                    <div class="w3-row w3-padding-top w3-padding-bottom">
                        <input type="text" autofocus="autofocus" maxlength="18" required="required" placeholder="Tên đăng nhập" />
                    </div>
                    <div class="w3-row w3-padding-top w3-padding-bottom">
                        <input type="password" autofocus="autofocus" maxlength="18" required="required" placeholder="Mật khẩu" />
                    </div>
                    <div class="w3-row w3-padding-top w3-padding-bottom">
                        <p class="checkbox w3-left">
                            <input type="checkbox" id="remember-res" />&nbsp;<label for="remember-res">Ghi nhớ</label>
                        </p>
                        <p class="w3-right"><a href="javascript:;" onclick="document.getElementById('forget-pass-modal').style.display = 'block';" class="w3-black w3-text-brown w3-hover-text-white">Quên mật khẩu ?</a></p>
                    </div>
                    <div class="w3-row w3-padding w3-center">
                        <a href="javascript:;" class="w3-btn w3-brown w3-hover-white w3-hover-text-brown" style="width: 100%">Đăng nhập</a>
                    </div>
                    <p class="w3-center">Hoặc đăng nhập bằng</p>
                    <div class="w3-row w3-padding w3-center">
                        <a href="javascript:;" class="w3-btn w3-indigo w3-hover-white w3-hover-text-indigo w3-half"><i class="fa fa-facebook"></i>&nbsp;Facebook</a>
                        <a href="javascript:;" class="w3-btn w3-deep-orange w3-hover-white w3-hover-text-deep-orange w3-half"><i class="fa fa-google-plus"></i>&nbsp;Google+</a>
                    </div>
                </div>
            </li>
        </ul>
    </div>
    <%
            }
            else
            {
                var get_user = new TblUserController().FetchAll().Where(x => x.UserName.ToLower() == user.ToLower()).Single();
                Session["user"] = user;
                Session["level"] = get_user.UserLevel;
                Session["user_id"] = get_user.UserId;
                HttpCookie ck = new HttpCookie("user");
                ck.Value = get_user.UserId.ToString();
                Response.Cookies.Add(ck);
            }
        }
        
    %>
</body>
</html>
